package org.crazyit.cloud;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.core.env.Environment;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RefreshScope  //配置刷新注解http://localhost:{server.port}/bus/refresh  post访问此地址就可刷新配置文件
public class TestController {

	@Autowired
	private Environment env;//获取属性的方式一
	
	@Value("${hello}")
	private  String hello;//获取属性的方式二
	 
	@RequestMapping(value = "/hello", method = RequestMethod.GET)
	public String getHello() {
		return env.getProperty("hello");
	}
	
	@RequestMapping(value = "/hello1", method = RequestMethod.GET)
	public String getHello1() {
		return hello;
	}
}
